package com.chen;

import com.chen.conf.SchoolConfiguration;
import com.chen.conf.SchoolProperties;
import com.chen.entity.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;

@Configuration
@Import(com.chen.conf.SchoolConfiguration.class)
@EnableConfigurationProperties(SchoolProperties.class)
public class SchoolSpringBootAutoConfiguration {
    @Autowired
    private School school;
    @Autowired
    private SchoolProperties schoolProperties;

    @Bean
    public void setSchoolAttributes(){
        String schoolName = schoolProperties.getSchoolName();
        if (schoolName != null){
            school.setName(schoolName);
        }
    }
}
